package com.chif.excel;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class EasyExcelController {

    @PostMapping("import")
    public void readExcel(MultipartFile file) {
        ExcelUtil.read(file, UserImportDTO.class, t -> {
            // 模拟service中业务异常
            if (!t.getName().startsWith("No.")) {
                throw new LyException.Normal("学号必须以\"No.\"开头");
            }

            // 模拟service中业务异常
            t.setEmail1("测试注入");
            t.setEmail2(null);
        });
    }

}
